package com.gec.utils;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.Map;
import java.util.Set;

public class Tool {

    public static boolean isEmpty(String string) {
        return string == null || "".equals(string);
    }

    public static boolean isNotEmpty(String string) {
        return !isEmpty(string);
    }

    /**
     * 参数数组中，只要有一个参数为null或空字符串，将会返回true
     * @param objects
     * @return
     */
    public static boolean parameterIsEmpty(String... objects) {
        for (String object : objects) {
            if (isEmpty(object)) {
                return true;
            }
        }
        return false;
    }

    /**
     * 打印所有请求参数
     *
     * @param request
     */
    public static  void printAllRequestParameter(HttpServletRequest request) {
        System.out.println("-----【全部请求参数】-----");
        final Map<String, String[]> parameterMap = request.getParameterMap();
        final Set<String> keySet = parameterMap.keySet();
        for (String key : keySet) {
            System.out.println(key + "--->" + Arrays.toString(parameterMap.get(key)));
        }
        System.out.println("-----------------------");
    }



}
